package com.华为OD.牛客;
import java.util.HashSet;
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class HJ28 {
    public static boolean isPrime1(int x) {
        for (int i = 2; i <= Math.sqrt(x); i++)
            if (x % i == 0)
                return false;
        return true;
    }
    public static HashSet<Integer>hs = new HashSet<>();
    public static int dfs(){
        if(hs.isEmpty())
            return 0;
        int[] nums = hs.stream().mapToInt(x->x).toArray();
        int x0 = nums[0];
        hs.remove(x0);
        int max = 0;
        for(int i = 1;i<nums.length;i++){
            int x = nums[i];
            hs.remove(x);
            int n = (isPrime1(x+x0)?1:0)+dfs();
            hs.add(x);
            max = Math.max(max,n);
        }
        hs.add(x0);
        return max;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for(int i = 0;i<n;i++){
            hs.add(in.nextInt());
        }
        System.out.print(dfs());
    }
}
